import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { ApiProperty } from '@nestjs/swagger';
import { HydratedDocument, Document } from 'mongoose';

export type UserDocument = HydratedDocument<User>;

@Schema()
export class User extends Document {
  @ApiProperty({ description: '手机号' })
  @Prop({ type: String, required: true })
  phone: string; // 手机号

  @ApiProperty({ description: 'WaiF号' })
  @Prop({ type: String })
  WaiFCode: string; // WaiF号

  @ApiProperty({ description: '密码' })
  @Prop({ type: String, required: true })
  password: string; // 密码

  @ApiProperty({ description: '昵称' })
  @Prop({ type: String, required: true })
  nick: string; // 昵称

  @ApiProperty({ description: '用户头像地址' })
  @Prop({ type: String, required: true, default: '/user_pic.png' })
  imgUrl: string; // 用户头像地址

  @ApiProperty({ description: '性别' })
  @Prop({ type: String, default: '未知' })
  sex: string; // 性别

  @ApiProperty({ description: '年龄' })
  @Prop({ type: Number, default: 0 })
  age: number; // 年龄

  @ApiProperty({ description: '生日' })
  @Prop({ type: String, default: '' })
  birthday: string; // 生日

  @ApiProperty({ description: '星座' })
  @Prop({ type: String, default: '' })
  start: string; // 星座

  @ApiProperty({ description: '个性签名' })
  @Prop({ type: String, default: '这个人很高冷, 暂时没有留下什么' })
  sign: string; // 个性签名

  @ApiProperty({ description: '用户身份' })
  @Prop({ type: String, required: true })
  token: string; // 用户身份

  @ApiProperty({ description: '账号是否可用' })
  @Prop({ type: Boolean, default: true, required: true })
  isStatus: boolean; // 账号是否可用

  @ApiProperty({ description: '是否是管理员' })
  @Prop({ type: Boolean, default: false, required: true })
  isAdmin: boolean; // 是否是管理员
}

export const UserSchema = SchemaFactory.createForClass(User);
